<?php

namespace app\controllers;
use myVendor\Factorys;

class BackendController extends BaseController
{
    function beforeAction($action)
    {
        $UserService=Factorys::getUserService();
        if($UserService->checkIsGuest()) {
            return $this->redirect(['/login']);
        }
        else
            return true;
    }

    //输出
    public function response($success=1,$messate="",$data=[])
    {
        $response = \Yii::$app->response;
        $response->format =  $response::FORMAT_JSON ;
        $response->data =["success"=>$success, "message"=>$messate,"data"=>$data];
        return $response;
    }
}
